package com.banmao.desktoptools;

import com.banmao.desktoptools.baseScene.view.BaseSceneView;
import com.banmao.desktoptools.splashScreen.MySplashScreen;
import com.banmao.desktoptools.testmybatis.dao.TestMybatisDao2;
import com.banmao.desktoptools.testmybatis.dao.TestMybatisMapper;
import com.banmao.desktoptools.testmybatis.vo.UserPojo;
import de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;

//@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
//@ServletComponentScan
//@MapperScan({"com.banmao"})
@Slf4j
@SpringBootApplication
public class DesktopToolsApplication implements CommandLineRunner {

	private static final Double START_TIME = (double) System.currentTimeMillis();

	public static void main(String[] args) {
		log.info("开始运行");
		//ConfigurableApplicationContext context = SpringApplication.run(DesktopToolsApplication.class, args);
		//SpringApplication.run(DesktopToolsApplication.class, args);

		//AbstractJavaFxApplicationSupport.launch(DesktopToolsApplication.class,
		//		FXMain.class, BaseSceneView.class, args);

		AbstractJavaFxApplicationSupport.launch(DesktopToolsApplication.class, FXMain.class,
				BaseSceneView.class, new MySplashScreen(), args);
	}

	private TestMybatisDao2 testMybatisDao2;

	@Autowired
	public void setTestMybatisDao2(TestMybatisDao2 testMybatisDao2) {
		this.testMybatisDao2 = testMybatisDao2;
	}

	@Override
	public void run(String... args) {
		// 启动时自动初始化数据库连接
		new Thread(() -> {
			//Boolean b = testMybatisDao2.initSQL();
			//if(b != null) {
			//}
		}).start();

		log.info("启动时间: {}", (System.currentTimeMillis() - START_TIME) / 1000);

	}
}
